package com.sike.controller.usertext;

import com.sike.Dao.UserDao;
import com.sike.entity.ResponseData;
import com.sike.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author vito
 * @version 1.0
 */
@RestController
@RequestMapping("/exception")
public class ExceptionController {
    @GetMapping("/test1")
    public ResponseData test1() {
        int[] arr = {1, 2, 3};
        arr = null;
        System.out.println(arr[0]);
        //以下是正常代码
        Map<Integer, User> users = UserDao.findAllUsers();
        return new ResponseData("200", null, true, users);
    }

    @GetMapping("/test2")
    public ResponseData tset2() {
        int[] arr = {1, 2, 3};
        System.out.println(arr[3]);
        //以下正常代码
        Map<Integer,User> users=UserDao.findAllUsers();
        return new ResponseData<>("200",null,true,users);
    }
    @GetMapping("/test3")
    public ResponseData tset3() {
        int[] arr = {1, 2, 3};
        int i = 10/0;
        //以下正常代码
        Map<Integer,User> users=UserDao.findAllUsers();
        return new ResponseData<>("200",null,true,users);
    }


}
